import pickle
from abc import ABC, abstractmethod


class AbstractDBStrategy(ABC):

    @abstractmethod
    def save(self, file, obj):
        pass

    @abstractmethod
    def load(self, file):
        pass


class FileDBStrategy(AbstractDBStrategy):

    def save(self, file, obj):
        print("saving")
        try:
            with open(file, "wb") as f:
                pickle.dump(obj, f)
        except Exception as e:
            print(e.args[0])

    def load(self, file):
        print("loading")
        try:
            with open(file, "rb") as f:
                return pickle.load(f)
        except Exception as e:
            print(e.args[0])
